home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 September / PCWorld_2006-09_cd.bin / komercni software / zoner / zps8_cz.exe / {app} / HTMLPublish / compactPHP.zht / imgcmt2.php < prev    next >
PHP Script  |  2006-03-22  |  3KB  |  127 lines

  1. <?php
  2.  
  3. $entry = "<i>%who%</i>%details% %time% (%ip%) %remove%<bR>%text%<br><br>";
  4. $result = "";
  5. $counter = 0;
  6.  
  7. include_once("fn.php");
  8.  
  9. function startElementE($parser, $name, $attrs) 
  10. {
  11.    if (strcmp($name,"COMMENT")==0)
  12.    {
  13.      global $entry;
  14.      global $result;
  15.      global $counter;
  16.  
  17.      $entrym1 =  " (<a href=\"mailto:%mail%\">e-mail</a>, <a href=\"%web%\">web</a>)";
  18.      $entrym2 =  " (<a href=\"mailto:%mail%\">e-mail</a>)";
  19.      $entrym3 =  " (<a href=\"%web%\">web</a>)";
  20.  
  21.      $res=str_replace("%who%",charDecode($attrs['PERSON']),$entry);
  22.      $res=str_replace("%text%",charDecode($attrs['TEXT']),$res);
  23.      $res=str_replace("%ip%",charDecode($attrs['IP']),$res);
  24.  
  25.      $counter++;
  26.      $removelnk = " <a href=\"remcmt.php?file=%fileid%&id=".$counter."\">odstranit</a>";
  27.      $res=str_replace("%remove%",$removelnk,$res);
  28.  
  29.  
  30.      $tm=$attrs['TIME'];
  31.      if (strcmp($tm,"")!=0)
  32.         $tm=date("d.m.Y H:i:s",$tm);
  33.      $res=str_replace("%time%",$tm,$res);
  34.  
  35.      $entrym="";
  36.      if (strcmp($attrs['MAIL'],"")!=0)
  37.      {
  38.     if (strcmp($attrs['WEB'],"")!=0 && strcmp($attrs['WEB'],"http://")!=0)
  39.        $entrym=$entrym1;
  40.         else
  41.        $entrym=$entrym2;
  42.      }
  43.      else
  44.     if (strcmp($attrs['WEB'],"")!=0 && strcmp($attrs['WEB'],"http://")!=0)
  45.        $entrym=$entrym3;
  46.      $resm=str_replace("%mail%",charDecode($attrs['MAIL']),$entrym);
  47.      $resm=str_replace("%web%",charDecode($attrs['WEB']),$resm);
  48.      
  49.      $res=str_replace("%details%",$resm,$res);
  50.  
  51.      $result=$result.$res;
  52.    }
  53. }
  54.  
  55. function endElementE($parser, $name) 
  56. {
  57. }
  58.  
  59. function vshowcomments($id)
  60. {
  61. $soubor="text/%num%.cmt";
  62. $soubor=str_replace("%num%",$id,$soubor);
  63. global $result;
  64. global $counter;
  65.  
  66. if (file_exists($soubor)) 
  67. {
  68.   $xml_parser = xml_parser_create();
  69.   xml_set_element_handler($xml_parser, "startElementE", "endElementE");
  70.   if (!($fp = fopen($soubor, "r"))) {
  71.      die("could not open XML input");
  72.   }
  73.  
  74.   while ($xmldata = fread($fp, 4096)) {
  75.      if (!xml_parse($xml_parser, $xmldata, feof($fp))) {
  76.          die(sprintf("XML error: %s at line %d",
  77.                      xml_error_string(xml_get_error_code($xml_parser)),
  78.                      xml_get_current_line_number($xml_parser)));
  79.      }
  80.   }
  81.   xml_parser_free($xml_parser);
  82. }
  83. $result=str_replace("%fileid%",$id,$result);
  84. $copy=$result;
  85. $result="";
  86. $counter=0;
  87. return $copy;
  88. }
  89.  
  90. $cmtcount=0;
  91. function startElementC($parser, $name, $attrs) 
  92. {
  93.   global $cmtcount;
  94.   if (strcmp($name,"COMMENTS")==0)
  95.   {
  96.      $cmtcount=(int)$attrs['COUNT'];
  97.   }
  98. }
  99.  
  100. function vgetcommentcount($id)
  101. {
  102. $soubor="text/%num%.cmt";
  103. $soubor=str_replace("%num%",$id,$soubor);
  104. global $cmtcount;
  105.  
  106. if (file_exists($soubor)) 
  107. {
  108.   $xml_parser = xml_parser_create();
  109.   xml_set_element_handler($xml_parser, "startElementC", "endElementE");
  110.   if (!($fp = fopen($soubor, "r"))) {
  111.      die("could not open XML input");
  112.   }
  113.  
  114.   while ($xmldata = fread($fp, 4096)) {
  115.      if (!xml_parse($xml_parser, $xmldata, feof($fp))) {
  116.          die(sprintf("XML error: %s at line %d",
  117.                      xml_error_string(xml_get_error_code($xml_parser)),
  118.                      xml_get_current_line_number($xml_parser)));
  119.      }
  120.   }
  121.   xml_parser_free($xml_parser);  
  122. }
  123. return $cmtcount;
  124. }
  125.  
  126. ?>
  127.